//#pragma once
#ifndef __AUDIOHOST_H__
#define __AUDIOHOST_H__

#include "Mixer.h"
//#include "ServerMixer.h"
#include "Gate.h"

class CAudioHost
{
protected:
	CChannelForMixer* pCChnl;
	CChannelForMixer* pLChnl;
	CMixer* pMixer;
	//CServerMixer* pMixer;
	Gate* pGate;
	long nBufsz;
	volatile float* pLBuf;
	volatile float* pRBuf;

	static void __stdcall InBufferCallBack (float* lChnl,float* rChnl,int nSamples,CChannelForMixer* obj,void* context);
	static void __stdcall OutBufferCallBack (float* lChnl,float* rChnl,int nSamples,CChannelForMixer* obj,void* context);

	void SetSampleRate(unsigned int iSamplePerSec);
public:
	CAudioHost(void);
	~CAudioHost(void);
	CChannelForMixer* GetCaptureChannel(void);
	CChannelForMixer* GetListenChannel(void);
	unsigned long HandleSamples8Bit(char* pBuf, unsigned long n);
	unsigned long HandleSamples16Bit(char* pBuf, unsigned long n);
	unsigned long HandleSamples24Bit(char* pBuf, unsigned long n);
	unsigned long HandleSamples32Bit(char* pBuf, unsigned long n);
	unsigned long HandleSamplesRaw(float* p_lBuf, float* p_rBuf, unsigned long nSamples);
	bool BindMixer(CMixer* pM);
	//bool BindMixer(CServerMixer* pM);
	long SetBufferSize(long nSamples);
	long GetBufferSize(void);
	CMixer* GetBindedMixer(void);
	//CServerMixer* GetBindedMixer(void);
};

#endif